package com.ruoyi.web.controller.miniprogram;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 上传控制器
 * 处理小程序文件上传相关API请求
 *
 * @author ruoyi
 */
@Api("上传管理")
@RestController
@RequestMapping("/upload")
@CrossOrigin(origins = "*") // 允许跨域请求
public class UploadController extends BaseController
{
    
    /**
     * 上传头像
     */
    @ApiOperation("上传头像")
    @Log(title = "上传头像", businessType = BusinessType.INSERT)
    @PostMapping("/avatar")
    public AjaxResult uploadAvatar(@RequestParam("avatar") MultipartFile avatar, @RequestParam("userId") String userId)
    {
        // TODO: 实现头像上传逻辑
        return AjaxResult.success("上传成功", null);
    }
    
    /**
     * 上传已编码的图片
     */
    @ApiOperation("上传已编码的图片")
    @Log(title = "上传编码图片", businessType = BusinessType.INSERT)
    @PostMapping("/encodedImage")
    public AjaxResult uploadEncodedImage(@RequestParam("image") MultipartFile image, @RequestParam("userId") String userId)
    {
        // TODO: 实现已编码图片上传逻辑
        return AjaxResult.success("上传成功", null);
    }
    
    /**
     * 上传产品图片
     */
    @ApiOperation("上传产品图片")
    @Log(title = "上传产品图片", businessType = BusinessType.INSERT)
    @PostMapping("/product")
    public AjaxResult uploadProduct(@RequestParam("image") MultipartFile image, @RequestParam("productId") String productId)
    {
        // TODO: 实现产品图片上传逻辑
        return AjaxResult.success("上传成功", null);
    }
} 